/**
 * 
 */
package com.dalonedrau.graph;

import java.awt.Point;

import com.dalonedrau.jogl.util.UtilityMethods;
import com.dalonedrau.vectors.Vector2;

/**
 * @author Donald
 *
 */
public final class TwoDMapGraphNode extends GraphNode {
	/** the integer representing the node's map location. */
	private int location;
	/**
	 * Creates a new instance of {@link TwoDMapGraphNode}.
	 * @param ind the cell's index
	 * @throws Exception
	 */
	public TwoDMapGraphNode(final int ind, final Vector2 v) throws Exception {
		this(ind, (int) v.getX(), (int) v.getY());
	}
	/**
	 * Creates a new instance of {@link TwoDMapGraphNode}.
	 */
	public TwoDMapGraphNode() {
		
	}
	public TwoDMapGraphNode(final int ind, final Point pt) throws Exception {
		this(ind, pt.x, pt.y);
	}
	public TwoDMapGraphNode(final int ind, final int x, final int y) throws Exception {
		super(ind);
		location = UtilityMethods.getInstance().convertPointToInt(x, y);
	}
	public boolean equals(final Vector2 v) {
		return (location == UtilityMethods.getInstance().convertPointToInt(v));
	}
	public boolean equals(final Point pt) {
		return (location == UtilityMethods.getInstance().convertPointToInt(pt));
	}
	public boolean equals(final float x, final float y) {
		return (location 
				== UtilityMethods.getInstance().convertPointToInt(x, y));
	}
	/**
	 * Gets the node's coordinates.
	 * @return {@link Point}
	 */
	public Point getLocation() {
		return UtilityMethods.getInstance().convertIntToPoint(location);
	}
}
